package com.itheima.d7_interface_demo.practice;

import java.util.ArrayList;

public class StudentServiceImpl1 implements StudentService{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("--------全班学生信息如下-------");
        for (int i = 0; i < students.size(); i++) {
            Student stu = students.get(i);
            System.out.println("姓名：" + stu.getName() + ",性别：" + stu.getSex() + ",成绩：" + stu.getScore());
        }
        System.out.println("-----------------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double sum = 0;
        for (int i = 0; i < students.size(); i++) {
            Student stu = students.get(i);
            sum += stu.getScore();//累加
        }
        //求平均分
        System.out.println("平均分：" + sum / students.size());
    }
}
